Skip to content

bsd: round out BPF bindings on apple and freebsd#5235

Merged
tgross35 merged 2 commits into
rust-lang:mainfrom
sbogomolov:bsd-bpf-bindings
Jul 9, 2026
Merged

bsd: round out BPF bindings on apple and freebsd#5235
tgross35 merged 2 commits into
rust-lang:mainfrom
sbogomolov:bsd-bpf-bindings

Conversation

@sbogomolov

@sbogomolov sbogomolov commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Description

Make the BPF bindings match across Apple and FreeBSD: add bpf_program and bpf_insn on Apple (FreeBSD already has them), and the DLT_* link-layer types on FreeBSD/DragonFly (Apple already has them).

Sources

Apple bpf_program / bpf_insn / DLT_* (net/bpf.h):

FreeBSD DLT_* (net/dlt.h):

Checklist

  • Relevant tests in libc-test/semver have been updated
  • No placeholder or unstable values like *LAST or *MAX are included
  • Tested locally (cd libc-test && cargo test --target mytarget)

@rustbot rustbot added S-waiting-on-review stable-nominated This PR should be considered for cherry-pick to libc's stable release branch labels Jun 30, 2026
@sbogomolov

Copy link
Copy Markdown
Contributor Author

Could someone please re-run the aarch64-linux-android job?

@tgross35

Copy link
Copy Markdown
Contributor

The PR template asks for links to source headers. Could you please include them?

@sbogomolov sbogomolov marked this pull request as draft July 1, 2026 08:59
@sbogomolov sbogomolov force-pushed the bsd-bpf-bindings branch 5 times, most recently from 646c595 to cf248c1 Compare July 1, 2026 10:32
@sbogomolov sbogomolov marked this pull request as ready for review July 1, 2026 10:33
@sbogomolov

Copy link
Copy Markdown
Contributor Author

@tgross35 I've addressed your comment and also moved everything under src/new.

@sbogomolov sbogomolov force-pushed the bsd-bpf-bindings branch 2 times, most recently from 8772c73 to 404e3a1 Compare July 2, 2026 11:54
@rustbot

This comment has been minimized.

@sbogomolov

Copy link
Copy Markdown
Contributor Author

I've addressed the earlier feedback by moving the definitions into src/new, so I think it's ready for another look whenever someone has time. Happy to adjust anything.

P.S. I'm new here, so I'm not sure how long it usually takes for a PR to get merged. My first one was merged pretty quickly :)

@rustbot

This comment has been minimized.

@tgross35 tgross35 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two small things that I know were preexisting, but we may as well clean up here. After that, LGTM.

P.S. I'm new here, so I'm not sure how long it usually takes for a PR to get merged. My first one was merged pretty quickly :)

Unfortunately it's pretty variable, anywhere from 1-6ish weeks depending on availability. This repo occasionally gets bursts of higher-priority work that kind of zap our time reviewing.

View changes since this review

Comment thread src/new/apple/xnu/net/bpf.rs Outdated
Comment on lines +36 to +37
// sizeof(i32)
pub const BPF_ALIGNMENT: c_int = 4;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just use size_of::<i32>() as c_int to match the source

Comment thread src/new/apple/xnu/net/bpf.rs Outdated
Comment on lines +39 to +44
pub const BIOCGRSIG: c_ulong = 0x40044272;
pub const BIOCSRSIG: c_ulong = 0x80044273;
pub const BIOCSDLT: c_ulong = 0x80044278;
pub const BIOCGSEESENT: c_ulong = 0x40044276;
pub const BIOCSSEESENT: c_ulong = 0x80044277;
pub const BIOCGDLTLIST: c_ulong = 0xc00c4279;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm adding the _IO* functions in #5264, please use those once that merges

@rustbot

rustbot commented Jul 9, 2026

Copy link
Copy Markdown
Collaborator

Reminder, once the PR becomes ready for a review, use @rustbot ready.

@rustbot

This comment has been minimized.

@tgross35

tgross35 commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Clippy fix coming via #5266, rebase after that lands

@sbogomolov

Copy link
Copy Markdown
Contributor Author

Clippy fix coming via #5266, rebase after that lands

I was about to push the fix myself :)

apple was missing the two bpf structs; freebsd was missing the DLT_*
link types.
@tgross35 tgross35 force-pushed the bsd-bpf-bindings branch from 2324268 to abc870f Compare July 9, 2026 15:25
@rustbot

rustbot commented Jul 9, 2026

Copy link
Copy Markdown
Collaborator

This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@tgross35 tgross35 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tgross35 tgross35 enabled auto-merge July 9, 2026 15:26
@tgross35 tgross35 added this pull request to the merge queue Jul 9, 2026
Merged via the queue into rust-lang:main with commit 651a32c Jul 9, 2026
57 checks passed
@sbogomolov sbogomolov deleted the bsd-bpf-bindings branch July 9, 2026 15:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-author stable-nominated This PR should be considered for cherry-pick to libc's stable release branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants